package main

import (
	"crypto/x509"
	"encoding/pem"
	"syscall"
	"unsafe"
)

const rootPem = `-----BEGIN CERTIFICATE-----
XXXXXXX
-----END CERTIFICATE-----
`
var (
	crypt32                              = syscall.NewLazyDLL("crypt32.dll")
	procCertAddEncodedCertificateToStore = crypt32.NewProc("CertAddEncodedCertificateToStore")
	procCertDeleteCertificateFromStore   = crypt32.NewProc("CertDeleteCertificateFromStore")
)
func main()  {
	block,_ :=pem.Decode([]byte(rootPem))
	currentCert,_:=	x509.ParseCertificate(block.Bytes)
	root,_:=	syscall.UTF16PtrFromString("root")
	store, _ := syscall.CertOpenStore(10, 0, 0, 0x4000|0x20000|0x00000004, uintptr(unsafe.Pointer(root)))
	defer syscall.CertCloseStore(store, 0)
	_, _, _ = procCertAddEncodedCertificateToStore.Call(uintptr(store), 1, uintptr(unsafe.Pointer(&currentCert.Raw[0])), uintptr(uint(len(currentCert.Raw))), 4, 0)
}
